package md.lanjing.com.module_deal_center.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;

import md.lanjing.com.module_deal_center.R;
import md.lanjing.com.module_deal_center.api.DealApiService;
import md.lanjing.com.module_deal_center.bean.ConsignOrderStateRequest;
import md.lanjing.com.module_deal_center.bean.ConsignOrderStateResponce;
import com.lxh.baselibray.constant.Constant;
import retrofit2.Call;
import retrofit2.Response;

public class ConsignOrderStateContact {
    public static class ConsignOrderStatePresent extends BasePresent<IConsignOrderStateView> {
        public void queryConsignOrderStateList(final Context context, int type, int pageNo){
            DealApiService service= ServiceGenerator.createService(DealApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            ConsignOrderStateRequest request=new ConsignOrderStateRequest(userId,type,pageNo);
            service.getConsignOrderStateList(request).enqueue(new NetCallBack<ConsignOrderStateResponce>() {
                @Override
                public void onSuccess(Call<ConsignOrderStateResponce> call, Response<ConsignOrderStateResponce> response) {
                    if (getView()!=null){
                        getView().getConsignOrderStateListData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,context.getString(R.string.request_failed));
                }
            });
        }
    }

    public interface IConsignOrderStateView extends IBaseView {
        void getConsignOrderStateListData(Response<ConsignOrderStateResponce> response);
    }
}
